package com.test.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 
 * 
 * 
 * @author wesley.wei
 *
 */
@Controller
@RequestMapping(value = "/test/redis")
public class RedisController {

	@Autowired
	private StringRedisTemplate redisTemplate;
	
	/**
	 * 设置一个值

	 * @Author:wesley
	 * @Time:2018年1月19日上午11:27:08
	 */
	@RequestMapping(value = "/setV")
	@ResponseBody
	public String env(String para) throws Exception {
		redisTemplate.opsForValue().set("testeng", para);
		String str = redisTemplate.opsForValue().get("testeng");
		
		return str;
	}
	
	
	
	@RequestMapping(value = "/setListV")
	@ResponseBody
	public String setListV() throws Exception {
		redisTemplate.opsForList().leftPushAll("msg", "hello,xiandafu");
		redisTemplate.opsForList().leftPushAll("msg", "hello,springboot");
		return "OK";
	}
	
}
